﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebComponents.Data;
using WebComponents.Security;
using System.Web.Security;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
namespace WebComponents.UI.Controls
{
    public static class AutoComplete
    {
        #region AjaxControlToolkit AutoComplete
        public static void DynamicAutoComplete(AjaxControlToolkit.AutoCompleteExtender autoComplete, string contextKey)
        {
            autoComplete.ServicePath = "~/WebServices/wscAutoComplete.asmx";
            autoComplete.ServiceMethod = "AutoComplete";
            autoComplete.UseContextKey = true;
            autoComplete.ContextKey = DataCrypt.Encrypt(contextKey);
            autoComplete.EnableCaching = true;
            //js
            if (autoComplete.OnClientPopulated == "")
                autoComplete.OnClientPopulated = "axCOnClientPopulated";
            if (autoComplete.OnClientItemSelected == "")
                autoComplete.OnClientItemSelected = "axCOnClientItemSelected";
            //css
            if (autoComplete.CompletionListCssClass == "")
                autoComplete.CompletionListCssClass = "axCList";
            else
                autoComplete.CompletionListCssClass = String.Format("axCList {0}", autoComplete.CompletionListCssClass);

            if (autoComplete.CompletionListItemCssClass == "")
                autoComplete.CompletionListItemCssClass = "axCListItem";
            else
                autoComplete.CompletionListItemCssClass = String.Format("axCListItem {0}", autoComplete.CompletionListItemCssClass);

            if (autoComplete.CompletionListHighlightedItemCssClass == "")
                autoComplete.CompletionListHighlightedItemCssClass = "axCHoverItem";
            else
                autoComplete.CompletionListHighlightedItemCssClass = String.Format("axCHoverItem {0}", autoComplete.CompletionListHighlightedItemCssClass);
        }
        #endregion
    }
}
